<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title></title>
  <script src="https://cdn.bootcss.com/react/16.4.0/umd/react.development.js"></script>
  <script src="https://cdn.bootcss.com/react-dom/16.4.0/umd/react-dom.development.js"></script>
  <script src="https://cdn.bootcss.com/babel-standalone/6.26.0/babel.min.js"></script>
</head>

<body>
  <div id="root">

  </div>
</body>

</html>

<script type="text/babel">
    /**
 * react的生命周期分成三种
 * 1. mount 挂载
 * 2. update 更新
 * 3. unmount 卸载
 */

 class Hello extends React.Component {

    componentWillMount() {
        console.log('即将挂载');
    }

    componentDidMount() {
        console.log('已挂载');
    }

    componentWillUpdate(nextProps, nextState) {
        console.log('将要更新');
    }

    componentDidUpdate(prevProps, prevState) {
        console.log('更新完毕');
    }

    // 默认每一次的修改都触发页面更新,此函数用于干预是否要更新,用于性能优化,
    shouldComponentUpdate(nextProps, nextState) {

    }

    componentWillUnmount() {
        console.log('将要卸载');
    }

    render() {
        return <div>生命周期</div>
    }
 }

ReactDOM.render(
  <Hello name="world"/>,
  document.getElementById('root')
);
</script>